package com.blacktea.cloudproviderhystrixpayment.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.blacktea.cloudapicommon.beans.Payment;
import com.blacktea.cloudproviderhystrixpayment.mapper.PaymentMapper;
import com.blacktea.cloudproviderhystrixpayment.service.PaymentService;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author blacktea
 * @since 2021-07-28
 */
@Service
public class PaymentServiceImpl extends ServiceImpl<PaymentMapper, Payment> implements PaymentService {

    @Override
    public String paymentInfoSuccess(Long id){
        return "线程："+Thread.currentThread().getName()+"   paymentInfo_OK,id：  "+id+"\t"+"哈哈哈"  ;
    }

    @Override
    public String paymentInfoTimeOut(Long timout){
        long start = System.currentTimeMillis();
        try { TimeUnit.SECONDS.sleep(timout); }catch (Exception e) {e.printStackTrace();}
        return "线程："+Thread.currentThread().getName()+"   paymentInfo_TimeOut,timout：  "+timout+"s等待,"+" 耗时(毫秒)"+(System.currentTimeMillis()-start);
    }
}